<template>
	<BaseContainer>
		<p class="nav-title">对接工单时间限制</p>
		<ul class="nav-box" v-loading="loading">
			<li class="nav-item" v-for="(item, index) in dataList" :key="index">
				<p>{{ item.label }}:</p>
				<el-switch v-model="item.value" active-value="1" inactive-value="0" @change="onChange(item)" />
			</li>
		</ul>
	</BaseContainer>
</template>

<script setup lang="ts">
import apiMod from '@/apiMod/index'
const val = ref('')
const dataList = ref([])
const loading = ref(false)
const getInitData = () => {
	apiMod.getDictItemList(['ORDER_TIME_LIMIT']).then((res) => {
		const data = res.data?.ORDER_TIME_LIMIT
		dataList.value = data || []
	})
}

const onChange = (item) => {
	loading.value = true
	apiMod
		.sys_dict_item_edit({ ...item })
		.then(() => {
			loading.value = false
			ElMessage.success('操作成功!')
			getInitData()
		})
		.catch(() => {
			loading.value = false
		})
}
onMounted(() => {
	getInitData()
})
</script>

<style scoped lang="scss">
.nav-box {
	.nav-item {
		display: flex;
		align-items: center;
		gap: 30px;
		border-bottom: 1px solid #eee;
	}
}
</style>
